#pragma once
#include "..\Common\Preferences.h"
#include "..\Common\bkddx.h"
#include "..\MainDlg.h"

class CEditImpl : public CWindowImpl<CEditImpl, CEdit>
{
    BEGIN_MSG_MAP(CEditImpl)
        MSG_WM_CONTEXTMENU(OnContextMenu)
    END_MSG_MAP()

    void OnContextMenu ( HWND hwndCtrl, CPoint ptClick )
    {
       // MessageBox("Edit control handled WM_CONTEXTMENU");
    }
};

class CSettingDlg 
	: public CBkDialogImpl<CSettingDlg>
	,public CWHRoundRectFrameHelper<CSettingDlg>
	,public CWinDataExchange<CSettingDlg>
{
public:
	CSettingDlg(CMainDlg* m_dlg)
		: CBkDialogImpl<CSettingDlg>(IDR_BK_SETTING_DLG)
	{
		m_MainDlg = m_dlg;
	
	}

	~CSettingDlg(void)
	{		
	}

	LRESULT		OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	BOOL		OnInitDialog(HWND wParam, LPARAM lParam);	
	LRESULT		OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	void		OnBkBtnClose();
	void		OnBkBtnSure();	
	void OnDataExchangeError ( UINT nCtrlID, BOOL bSave );


public:
	BK_NOTIFY_MAP(IDC_RICHVIEW_WIN);
		BK_NOTIFY_ID_COMMAND(IDC_BTN_SYS_CLOSE,					OnBkBtnClose)
		BK_NOTIFY_ID_COMMAND(IDC_BTN_DLG_OK,			OnBkBtnSure)
		BK_NOTIFY_ID_COMMAND(IDC_BTN_DLG_CANCEL,		OnBkBtnClose)		

	BK_NOTIFY_MAP_END()

	BEGIN_MSG_MAP_EX(CSettingDlg)	
		MSG_BK_NOTIFY(IDC_RICHVIEW_WIN)
		CHAIN_MSG_MAP(CBkDialogImpl<CSettingDlg>)
		CHAIN_MSG_MAP(CWHRoundRectFrameHelper<CSettingDlg>)
		MESSAGE_HANDLER(WM_CREATE,				OnCreate)
		MESSAGE_HANDLER(WM_DESTROY,				OnDestroy)	
		MSG_WM_INITDIALOG(OnInitDialog)	

		REFLECT_NOTIFICATIONS_EX()
	END_MSG_MAP()		
	BEGIN_DDX_MAP(CSettingDlg)
        DDX_CONTROL(IDC_SETTING_PSW_LOCK_TEXT, m_EditLockTime)
		DDX_CONTROL(IDC_SETTING_PSW_CLEAR_S, m_EditClearTime)
		DDX_CONTROL(IDC_SETTING_PSW_MIN_LEN, m_EditMinLen)
		DDX_CONTROL(IDC_SETTING_PSW_QUAL_LEN, m_EditQualLen)
		DDX_CONTROL(IDC_SETTING_PSW_GENPROFILE, m_EditGenProfile)
		DDX_CONTROL(IDC_SETTING_TBX_TRANS_TEXT, m_EditTbTrans)
		DDX_CONTROL(IDC_SETTING_TBX_FLOAT_TRS_TEXT, m_EditFloatTrans)

		DDX_INT(IDC_SETTING_PSW_LOCK_TEXT, thePrefs.m_PswSettings.Idle_Second )
		DDX_INT(IDC_SETTING_PSW_CLEAR_S, thePrefs.m_PswSettings.Wait_Second )
		DDX_INT(IDC_SETTING_PSW_MIN_LEN, thePrefs.m_PswSettings.Psw_Min_Len)
		DDX_INT(IDC_SETTING_PSW_QUAL_LEN, thePrefs.m_PswSettings.Psw_Qual_Len)
		DDX_TEXT(IDC_SETTING_PSW_GENPROFILE, thePrefs.m_PswSettings.Genp_Profile)
		DDX_INT_RANGE(IDC_SETTING_TBX_TRANS_TEXT, thePrefs.m_TbxSettings.MTransparent_Value,0,255)
		DDX_INT_RANGE(IDC_SETTING_TBX_FLOAT_TRS_TEXT, thePrefs.m_TbxSettings.FTransparent_Value,0,255)

		DDX_CHECK(IDC_SETTING_DF_KNL,thePrefs.m_MainSettings.Default_Knowledge);
		DDX_CHECK(IDC_SETTING_DF_PSW,thePrefs.m_MainSettings.Default_Password);
		DDX_CHECK(IDC_SETTING_DF_TBX,thePrefs.m_MainSettings.Default_Toolbox);
		DDX_CHECK(IDC_SETTING_UPG_A,thePrefs.m_MainSettings.Auto_Upgrade);
		DDX_CHECK(IDC_SETTING_UPG_Q,thePrefs.m_MainSettings.Manual_Upgrade);
		DDX_CHECK(IDC_SETTING_PROXY,thePrefs.m_MainSettings.Use_Proxy);
		DDX_CHECK(IDC_SETTING_AUTOSTART,thePrefs.m_MainSettings.Auto_Start);

		DDX_CHECK(IDC_SETTING_PSW_LOCK_MIN,thePrefs.m_PswSettings.Lock_When_Min);
		DDX_CHECK(IDC_SETTING_PSW_LOCK_SWITCH,thePrefs.m_PswSettings.Lock_When_Switch);
		DDX_CHECK(IDC_SETTING_PSW_LOCK_IDLE,thePrefs.m_PswSettings.Lock_When_Idle);
		DDX_CHECK(IDC_SETTING_PSW_CLEAR,thePrefs.m_PswSettings.Clear_Clipboard);

		DDX_CHECK(IDC_SETTING_TBX_SHOW_MAX,thePrefs.m_TbxSettings.Show_Max);
		DDX_CHECK(IDC_SETTING_TBX_SHOW_MIN,thePrefs.m_TbxSettings.Show_Min);
		DDX_CHECK(IDC_SETTING_TBX_AUTO_HIDE,thePrefs.m_TbxSettings.Auto_Hide);
		DDX_CHECK(IDC_SETTING_TBX_TRANSPARENT,thePrefs.m_TbxSettings.Min_Transparent);
		DDX_CHECK(IDC_SETTING_TBX_SHOW_FLOATING,thePrefs.m_TbxSettings.Show_Floating);
		DDX_CHECK(IDC_SETTING_TBX_FLOAT_TRS,thePrefs.m_TbxSettings.Floating_Trpa);

    END_DDX_MAP()


private:
	void _init();
	CEditImpl			m_EditLockTime;
	CEditImpl			m_EditClearTime;
	CEditImpl			m_EditMinLen;
	CEditImpl			m_EditQualLen;
	CEditImpl			m_EditGenProfile;
	CEditImpl			m_EditTbTrans;
	CEditImpl			m_EditFloatTrans;
	CMainDlg*			m_MainDlg;
};